<?php
/**
 * CakeCMS - 后台公用处理
 * 功能模块:
 *
 * @author zzdboy
 * @version 1.0
 */
class PublicController extends AppController {
	public $components = array (
			'CheckUserPermission' 
	);
	
	/**
	 * 初始化执行
	 *
	 * @see AppController::beforeFilter()
	 */
	public function beforeFilter() {
		parent::beforeFilter ();
		
		// 判断是否登录
		$this->CheckUserPermission->checkLogin ( $this );
	}
	
	/**
	 * 后台地图
	 */
	public function map() {
		$this->loadModel ( "Menu" );
		
		$array = $this->Menu->admin_menu ( 0 );
		$map = "";
		$n = 1;
		foreach ( $array as $k => $v ) {
			if ($n == 1) {
				$map .= "<div class=\"map-menu lf\">";
			}
			$map .= "<ul>";
			$map .= "<li class=\"title\">{$v['Menu']['name']}</li>";
			$childmenus = $this->Menu->admin_menu ( $v ['Menu'] ['id'] );
			foreach ( $childmenus as $key => $r ) {
				$map .= "<li class=\"title2\">{$r['Menu']['name']}</li>";
				$menus = $this->Menu->admin_menu ( $r ['Menu'] ['id'] );
				foreach ( $menus as $s => $r ) {
					$map .= "<li><a href=\"javascript:Go({$r['Menu']['id']},'{$r['Menu']['controller']}')\">{$r['Menu']['name']}</a></li>";
				}
			}
			$map .= "</ul>";
			if ($n % 2 == 0) {
				$map .= "</div><div class=\"map-menu lf\">";
			}
			$n ++;
		}
		
		$this->set ( 'map', $map );
	}
}
?>